#include <iostream>

/*
    运算符重载+ 和 运算符重载-

*/

class Point
{
public:
    int x;
    int y;

    Point() : x(0), y(0) {}

    Point(int x, int y) : x(x), y(y)
    {
        std::cout << "构造函数调用了" << std::endl;
    }

    void display()
    {
        std::cout << "X: " << x << "\tY: " << y << std::endl;
    }

    Point operator-(const Point &p)
    {
        return {x - p.x, y - p.y};
    }
};

Point operator+(const Point &p1, const Point &p2)
{
    // Point p = Point(p1.x + p2.x, p1.y + p2.y);
    // return p;
    return {p1.x + p2.x, p1.y + p2.y};
}

int main(int argc, char const *argv[])
{
    

    Point p1(10, 20);

    Point p2(5, 6);

    p1.display();
    p2.display();

    Point p3 = p1 + p2;
    p3.display();

    Point p4 = p1 - p2;
    p4.display();

    return 0;
}
